package cn.edu.neusoft.yuejian4.yuejian_4.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.yuejian4.yuejian_4.Config.Server;
import cn.edu.neusoft.yuejian4.yuejian_4.R;
import cn.edu.neusoft.yuejian4.yuejian_4.activity.MasterDetailActivity;
import cn.edu.neusoft.yuejian4.yuejian_4.javaBean.Master;

/**
 * Created by Lix on 2018/10/19.
 */

public class MasterQuestionAdapter extends RecyclerView.Adapter<MasterQuestionAdapter.ViewHolder>  {

    private List<Master> mMastersQuestion;
    private Context mContext;

    public MasterQuestionAdapter(Context mContext, List<Master> mMastersQuestion){
        this.mContext = mContext;
        this.mMastersQuestion = mMastersQuestion;
        //mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public MasterQuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.master_question_cardview,parent,false);
        MasterQuestionAdapter.ViewHolder holder = new MasterQuestionAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MasterQuestionAdapter.ViewHolder holder, int position) {
        final Master master = mMastersQuestion.get(position);
        holder.username.setText(master.getNickname()+":");
        holder.question.setText(master.getUser_question());
        holder.answer.setText(master.getAnswer());
    }

    @Override
    public int getItemCount() {
        return mMastersQuestion.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        TextView username,question,answer;

        public ViewHolder(View view){
            super(view);
            username = (TextView)view.findViewById(R.id.iq_username);
            question = (TextView)view.findViewById(R.id.iq_user_question);
            answer = (TextView)view.findViewById(R.id.iq_answer);

        }
    }
}
